import java.util.Scanner;

public class demo1 {

    public static int count = 0;
    public static void main(String[] args) {
    Object o = new Object();
        Thread t1 = new Thread(()->{
            synchronized (o){
                System.out.println("线程 t1 开始");
                while (count == 0){
                    try {
                        o.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }

                };

                System.out.println("线程 t1 结束");
            }
        });

        Thread t2 = new Thread(()->{
                System.out.println("输出:");
                Scanner scanner = new Scanner(System.in);
                synchronized (o){
                    count = scanner.nextInt();
                    o.notify();
                }
        });

        t1.start();
        t2.start();

    }
}



